package LeetcodeTest_thirty_eight;
//面试题 17.14. 最小K个数

import java.util.Arrays;

public class smallestK
{
    public static void main(String[] args)
    {
        int[] nums={1,5,7,3,4,0};
        int[] result=new int[3];
        result=Solutions.smallestK(nums,3);
        for(int i:result)
            System.out.println(i);
    }
}
class Solutions
{
    public static int[] smallestK(int[] arr, int k)
    {
        int n=arr.length;
        if(k>n)
            return null;
        if(k==n)
            return arr;
        int[] answer=new int[k];
        Arrays.sort(arr);
        for(int i=0;i<k;i++)
        {
            answer[i]=arr[i];
        }
        return answer;
    }
}